package com.base.themvx.adapter

import android.view.ViewGroup
import com.chad.library.adapter.base.module.LoadMoreModule

/**
 ******************(^_^)***********************<br>
 * Author: fee(QQ/WeiXin:1176610771)<br>
 * Date: 2023/8/10<br>
 * Time: 14:41<br>
 * <P>DESC:
 * 抽象数据适配器(以　ACommonViewHolder 作为　绑定　ItemVIew　数据与视图)
 * </p>
 * ******************(^_^)***********************
 */
abstract class AdapterWithCommonViewHolder<D, VH : ACommonViewHolder<D>> : ACommonAdapter<D, VH>(),
    LoadMoreModule {
    override fun onCreateDefViewHolder(parent: ViewGroup, viewType: Int): VH {
        return provideItemViewHolder(parent, viewType)
    }

    abstract fun provideItemViewHolder(parent: ViewGroup, viewType: Int): VH

    /**
     * Implement this method and use the helper to adapt the view to the given item.
     *
     * 实现此方法，并使用 helper 完成 item 视图的操作
     *
     * @param holder A fully initialized helper.
     * @param item   The item that needs to be displayed.
     */
    override fun convert(holder: VH, item: D) {
        holder.onBindView(item)
    }

    override fun convert(holder: VH, item: D, payloads: List<Any>) {
        holder.onBindView(item, payloads)
    }

}